#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>

#include "struct.h"
#include "readconfig.h"


void print_usage(char *progname)
{
	printf("%s usage:\n",progname);
	printf("-c(--config):Input the json file.\n");
	printf("-h(--help): print this help information.\n");
}



int mosq_argc(int argc,char **argv,mosquitto_t *mqtt)
{
	mosquitto_t  *mos;
	if(argc<0)
	{
		print_usage(argv[0]);
		return -1;
	}

	int ch = -1;

	struct option        opts[] = {
		{"--config",      required_argument, NULL, 'c'},
		{"help",        no_argument,       NULL, 'h'},
		{NULL,          0,                 NULL,  0 }
	};

	while((ch=getopt_long(argc,argv,"c:h",opts,NULL))!=-1)
	{
		switch(ch)
		{
			case 'c':
				read_json_file(argv[2],mqtt);

				break;
			case 'h':
				print_usage(argv[0]);
				return -1;

		}
	}

	return 0;

}
